Skip to content

[DO NOT MERGE] All spanner ut tests#3843

Open
darshan-sj wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
darshan-sj:all-ut
Open

[DO NOT MERGE] All spanner ut tests#3843
darshan-sj wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
darshan-sj:all-ut

Conversation

@darshan-sj
Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request is primarily dedicated to enhancing the testing infrastructure for Spanner-related data migration templates. By adding extensive unit tests for core utilities and DML generation logic, the changes aim to increase code reliability and maintainability. Additionally, the CI configuration has been optimized to provide more accurate and persistent coverage reporting across the project.

Highlights

  • Expanded Test Coverage: Added comprehensive unit tests across the spanner-common and spanner-to-sourcedb modules, covering DDL parsing, DML generation, and transformation logic.
  • CI/CD Configuration Updates: Updated .github/codecov.yml to refine component paths and enable 'carryforward' flags, ensuring more accurate and persistent coverage reporting in the monorepo.
  • Code Refactoring for Testability: Adjusted the visibility of several DML generator methods and utilities to facilitate better unit testing and mocking.
Ignored Files
  • Ignored by pattern: .github/workflows/** (6)
    • .github/workflows/bigtable-pr.yml
    • .github/workflows/datastream-pr.yml
    • .github/workflows/java-pr.yml
    • .github/workflows/kafka-pr.yml
    • .github/workflows/spanner-pr.yml
    • .github/workflows/yaml-pr.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.53%. Comparing base (f66b280) to head (d193b1a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3843      +/-   ##
============================================
+ Coverage     54.96%   55.53%   +0.56%     
- Complexity     6925     7002      +77     
============================================
  Files          1096     1096              
  Lines         67353    67354       +1     
  Branches       7558     7558              
============================================
+ Hits          37021    37402     +381     
+ Misses        27857    27538     -319     
+ Partials       2475     2414      -61     
Components Coverage Δ
spanner-templates 88.27% <100.00%> (+2.44%) ⬆️
spanner-import-export 68.65% <ø> (+0.12%) ⬆️
spanner-live-forward-migration 90.07% <ø> (+2.68%) ⬆️
spanner-live-reverse-replication 83.88% <100.00%> (+5.08%) ⬆️
spanner-bulk-migration 92.48% <ø> (+1.51%) ⬆️
gcs-spanner-dv 88.89% <ø> (+3.13%) ⬆️
Files with missing lines Coverage Δ
...2/templates/dbutils/dml/CassandraDMLGenerator.java 89.88% <100.00%> (+9.88%) ⬆️
...rt/v2/templates/dbutils/dml/MySQLDMLGenerator.java 97.26% <100.00%> (+8.14%) ⬆️
.../templates/dbutils/dml/PostgreSQLDMLGenerator.java 92.00% <100.00%> (+3.92%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly expands test coverage across the spanner-common, spanner-custom-shard, and spanner-to-sourcedb modules by introducing new unit tests for DDL components, DML generation logic, and change stream processing. It also updates the Codecov configuration and adjusts access modifiers to improve testability. Feedback was provided on a new Cassandra DML generator test where unconfigured mocks could lead to false positives.

Comment on lines +896 to +905
Table spannerTable = Mockito.mock(Table.class);
SourceTable sourceTable = Mockito.mock(SourceTable.class);
SourceColumn sourceCol = Mockito.mock(SourceColumn.class);

Mockito.when(sourceTable.primaryKeyColumns()).thenReturn(ImmutableList.of());
Mockito.when(sourceTable.columns()).thenReturn(ImmutableList.of(sourceCol));
Mockito.when(sourceCol.name()).thenReturn("col1");
Mockito.when(mockSchemaMapper.getSpannerColumnName("", "my_table", "col1"))
.thenThrow(new NoSuchElementException());
Mockito.when(sourceTable.name()).thenReturn("my_table");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The spannerTable mock is not configured with a name or schema. By default, spannerTable.getSchema() and spannerTable.getName() will return null. This causes the mock for mockSchemaMapper.getSpannerColumnName at line 903 (which expects "" and "my_table") to not match the actual call made in getColumnValues. As a result, the NoSuchElementException will not be thrown, and the test may pass for the wrong reason (e.g., by returning null instead of throwing). You should configure the spannerTable mock to match the expected arguments in the mockSchemaMapper stub.

    ISchemaMapper mockSchemaMapper = Mockito.mock(ISchemaMapper.class);
    Table spannerTable = Mockito.mock(Table.class);
    SourceTable sourceTable = Mockito.mock(SourceTable.class);
    SourceColumn sourceCol = Mockito.mock(SourceColumn.class);

    Mockito.when(spannerTable.getName()).thenReturn("my_table");
    Mockito.when(spannerTable.getSchema()).thenReturn("");
    Mockito.when(sourceTable.primaryKeyColumns()).thenReturn(ImmutableList.of());
    Mockito.when(sourceTable.columns()).thenReturn(ImmutableList.of(sourceCol));
    Mockito.when(sourceCol.name()).thenReturn("col1");
    Mockito.when(mockSchemaMapper.getSpannerColumnName("", "my_table", "col1"))
        .thenThrow(new NoSuchElementException());
    Mockito.when(sourceTable.name()).thenReturn("my_table");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant